package com.example.softpart.magicAPiCustomFunction;


import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.core.config.MagicFunction;
import org.ssssssss.script.annotation.Comment;
import org.ssssssss.script.annotation.Function;
import org.ssssssss.script.functions.DateExtension;

import java.util.Date;

@Component  //注入到Spring容器中
public class loginFunction implements MagicFunction {

    @Function
    @Comment("查询是否登录")
    public SaResult isLogin() {
        return SaResult.ok("是否登录：" + StpUtil.isLogin());
    }

    @Function
    @Comment("用户注销")
    public SaResult logout() {
        StpUtil.logout();
        return SaResult.ok();
    }
    @Function
    @Comment("获取satoken信息")

    public SaResult tokenInfo() {
        return SaResult.data(StpUtil.getTokenInfo());
    }
}
